package com.stylefeng.guns.core.util;

import lombok.extern.slf4j.Slf4j;
import org.kie.api.runtime.KieSession;

/**
 *
 */
@Slf4j
public class DroolsUtil {

    /**
     * @param kieSession
     * @param t
     * @param <T>
     */
    public synchronized static <T> void executeRule(KieSession kieSession, T t) {

        if (t != null) {
            kieSession.insert(t);
            kieSession.insert(log);
            int count = kieSession.fireAllRules();
            log.info("{}条规则被触发", count);
        }

    }
}
